Void Pointer
void*
is the loosely typed version of any pointer(like object
for non pointer types), the underlying type of the original pointer is mopped, so
- Cannot be deferenced.
- Arithmetic can not be performed.
Pointer comparison
Because an implicit conversion exists from any pointer type to the void*
type, operands of any pointer type can be compared using these operators. The comparison operators compare the addresses given by the two operands as if they were unsigned integers.
cs
bool operator ==(void* x, void* y);
bool operator !=(void* x, void* y);
bool operator <(void* x, void* y);
bool operator >(void* x, void* y);
bool operator <=(void* x, void* y);
bool operator >=(void* x, void* y);
1
2
3
4
5
6
2
3
4
5
6